package com.sinog.front.util;

import com.sinog.core.domain.Log;
import com.sinog.core.model.UserDTO;
import com.sinog.core.utilbean.IdGen;
import java.util.Date;

/**
 * @desc 用户操作日志工具类
 * @author lizhiqiang
 * @date -
 */
public final class UserToLogUtil {

    /**
     * 提取日志属性到Log
     * @param userDTO userDTO
     * @param type type
     * @param desc desc
     * @param param param
     * @param opInterface opInterface
     * @param ip ip
     * @return Log
     */
    public static Log converse(UserDTO userDTO,String type,String desc,String param,String opInterface,String ip) {
        Log log = new Log();
        log.setId(IdGen.strid());
        log.setAccount(userDTO.getAccount());
        log.setUsername(userDTO.getUsername());
        log.setDepartId(userDTO.getDepartid());
        log.setDepartName(userDTO.getDepartName());
        log.setOrgId(userDTO.getOrgid());
        log.setOrgName(userDTO.getOrgName());
        log.setPosition(userDTO.getPosition());
        log.setPositionName(userDTO.getPositionName());
        log.setPhone(userDTO.getPhone());
        log.setEmail(userDTO.getEmail());
        //其他信息
        log.setType(type);
        log.setContents(desc);
        log.setParam(param);
        log.setOpInterface(opInterface);
        log.setIp(ip);
        log.setCreateTime(new Date());
        return log;
    }
}